//THIS IS NOT A SCRIPT....It is a document displaying how to use the scripts system.

////Note, in order to load a script, all you have to do is place the file in the 
/scripts/ folder.  Any file with ".txt" extension will be loaded.  
All Procedure Names and Varaibles are not shared between files, so there is no need to worry about duplicate names. 
If you wish to have your script store data in a text file, just store it in the bot main folder(default anyways), or use a ".dat" extension.

All these are called by using ssc.Command Name (for attempted compatibility with SB Scripts)

If you wish to have Global Varaiables or Subs within your scripts, place them in a file called "Global.txt" within the script folder.  
  Global.txt is just a storage of Global Data/Functions, and is not called by the Bot Directly.
[I.e., if you made a sub called scream in globals.txt
Sub Scream()
	ssc.addChat "AHHHHHHH!!!!!",vbRed
End sub

   You could call "scream" from within any file

///////
Timer/Inet Control

-An inet control is exposed to the bot, called "scInet"
One command you can use with Inet is OpenURL.  EX:
ssc.addchat vbgreen, scInet.OpenURL("http://fool.the-brethren.com/news.txt") 'display news from foolops news server

-There is also a timer shared between all scripts.
Timer Settings can be modifed with the added ScriptTimer Object
ScriptTimer.Enabled=True, ScriptTimer.Interval=1000, etc.
When the timer fires it calles "Sub scTimer_Timer()"


/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////

'The-Fool 9/19/04
'Scripting Support Class
'Added to the scripting object to allow interaction with the bot


///////////////////
This will add a message to the que.  Prioirty should be 1, but you can change it
if you feel necessary.  I STRONGLY recommend you stick with the convention I use in my bot
1: Normal Messages/Que
2: Kicks/Unbans
3: Bans
4: Highest Priority Bans(These are usually bans that overflow from the special ban que).

Using priorities higher than necessary may interfere with the bots ability to moderate.
//////////////////////////////////////////////////////////////////

Public Sub AddQ(Message As String, Optional Priority As Integer = 1)
    Othercrap.AddQ Message, Priority
End Sub



//////  Returns the bots current trigger
Public Function getTrigger() As String
    getTrigger = Trigger
End Function







///Returns Access for a given Username
Public Function getUserAccess(Username) As Integer
    getAccess = getAccess(Username)
End Function





//returns access/Flags/Rank of a User, byRef
Usage example:

DIM access,flags,rank
getDBEntry username, access, flags, rank
IF access<60 THEN.....

/////////////////////////

Public Sub getDBEntry(ByVal Username, ByRef Access, ByRef Flags, ByRef Rank)

End Sub


//Adds text to the bot window
//Default color is vbWhite
//Adds one line per addchat, unless saveLine is set to true
//Then The next addchat statement will appear on the same bot window line.
Public Sub AddChat(Color, text, Optional saveLine = False)
    frmMain.AddChat txt, color, CBool(saveLine)
End Sub

//Calls a Command from the bots internal processor(including scripted bot commands).
Public Sub BotCommand(Command, Username, inbot)
    ParseCommand Command, Username, inbot
End Sub


//Provides an easy way to check for greater access.
//Returns true if Username has more access than ruser, and ruser isn't safelisted.
//Access 80+ will allow username to override the safelist.
Public Function banAccess(Username, rUser) As Boolean
    banAccess = validAccess(Username, rUser)
End Function

Public Function isSafeListed(Username) As Boolean
    isSafeListed = isSafeListed(Username)
End Function

//Allows you to perform a wildcard on the channel list.  The Function returns a string
//Array containing all the usernames that match the wildcard.

Example usage(could be inserted into commands processor):
Select case Command
   case "lameban"
	dim h
	if access<50 then exit function
	event_ParseCommand=" "
	If InStr(1, rest, "*") > 0 Then 'wildcard
        h=ssc.WCChannel(rest)
        For x = 1 To UBound(h)
            If ssc.banAccess(Username,h(x)) Then
                ssc.AddQ "/ban " & h(x) & " LameBan", 3
               'exit function
            Else
                nobancount = nobancount + 1
            End If
        Next 
	If UBound(h) = 0 Then
            Event_parsecommand = "No users found"
        ElseIf nobancount > 0 Then
            Event_ParseCommand = nobancount & " users not banned(due to access or safelist)"
        End If
    Else 'no wildcard
            If ssc.banAccess(Username, rest) Then
	            ssc.AddQ "/ban " & rest & " LameBan ", 3
            Else
                Event_ParseComamnd = "That user has higher access or is safelisted"
            End If
    End If
//////////////////////////////////////////////

Public Function WCChannel(Wildcard) As String()
    WCChannel = ChannelArray.WildCardChannel(Wildcard)
End Function




///A mimic of the VBs replace function(faster)
Public Function DoReplace(ByVal Expression As Variant, ByVal Find As Variant, ByVal Replace As Variant, _
    Optional ByVal start As Long = 1, Optional ByVal Count As Long = -1, Optional ByVal CompareMethod As Long = 0) As String

    DoReplace = Replace(Expression, Find, Replace, start, Count, CompareMethod)

End Function


///Evaluates the expression or runs a section of vbscript code
Public Function eval(Expression)
    frmMain.ScriptControl.eval Expression
End Function


//returns getTickCount Function
Public Function getGTC() As Long
    getGTC = GetTickCount
End Function


